import 'package:flutter/material.dart';
import 'package:zrjz/comm/utils/ex_widget.dart';

/// Notify的Error样式
class CustomErrorWidget extends StatelessWidget {
  const CustomErrorWidget({
    Key? key,
    required this.msg,
  }) : super(key: key);

  final String msg;

  @override
  Widget build(BuildContext context) {
    return _buildBg(children: [
      const Icon(Icons.error_outline, size: 38, color: Colors.white),
      Container(
        margin: const EdgeInsets.only(top: 15),
        child: Text(
          msg,
          style: const TextStyle(color: Colors.white, fontSize: 14),
          textAlign: TextAlign.center,
        ),
      ),
    ]);
  }

  Widget _buildBg({required List<Widget> children}) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 20),
      decoration: BoxDecoration(
        color: const Color(0xcc000000), //不使用传递的背景色 制定自己的背景颜色
        borderRadius: BorderRadius.circular(10),
      ),
      child: Column(mainAxisSize: MainAxisSize.min, children: children),
    ).constrained(maxWidth: 250);
  }
}
